package com.xbongbong.pro.enums.menu.enums;

import com.xbongbong.i18n.util.I18nMessageUtil;
import com.xbongbong.paas.enums.MenuTypeEnum;
import com.xbongbong.pro.enums.AccessLinkEnum;
import com.xbongbong.saas.enums.XbbRefTypeEnum;
import lombok.Getter;

/**
 * @author WuHB
 * @date 2022/10/26 11:11
 */
@Getter
public enum WorkOrderV2CenterMenuEnum {

    /*// 工单管理
    WORK_ORDER_V2_CENTER(XbbRefTypeEnum.WORK_ORDER_V2_CENTER.getName(), XbbRefTypeEnum.WORK_ORDER_V2_CENTER.getAlias(),
            XbbRefTypeEnum.WORK_ORDER_V2_CENTER.getCode(), AccessLinkEnum.WORK_ORDER_V2_CENTER, "", MenuTypeEnum.APP.getType()),*/
    // 全部工单
    WORK_ORDER_V2_ALL(XbbRefTypeEnum.WORK_ORDER_V2.getName(), XbbRefTypeEnum.WORK_ORDER_V2.getAlias(),
            XbbRefTypeEnum.WORK_ORDER_V2.getCode(), AccessLinkEnum.WORK_ORDER_V2_ALL, "", MenuTypeEnum.MENU.getType()),
    // 指派工单
    WORK_ORDER_V2_ASSIGN(XbbRefTypeEnum.WORK_ORDER_V2_APPOINT.getName(), XbbRefTypeEnum.WORK_ORDER_V2_APPOINT.getAlias(),
            XbbRefTypeEnum.WORK_ORDER_V2_APPOINT.getCode(), AccessLinkEnum.WORK_ORDER_V2_ASSIGN, "", MenuTypeEnum.MENU.getType()),
    // 工单池
    WORK_ORDER_V2_POOL(XbbRefTypeEnum.WORK_ORDER_V2_POOL.getName(), XbbRefTypeEnum.WORK_ORDER_V2_POOL.getAlias(),
            XbbRefTypeEnum.WORK_ORDER_V2_POOL.getCode(), AccessLinkEnum.WORK_ORDER_V2_POOL, "", MenuTypeEnum.MENU.getType()),
    // 回执单
    RECEIPT_ORDER(XbbRefTypeEnum.RECEIPT_ORDER.getName(), XbbRefTypeEnum.RECEIPT_ORDER.getAlias(),
            XbbRefTypeEnum.RECEIPT_ORDER.getCode(), AccessLinkEnum.RECEIPT_ORDER, "", MenuTypeEnum.MENU.getType()),

    // 服务项目
    SERVICE_PROJECT(XbbRefTypeEnum.SERVICE_PROJECT.getName(), XbbRefTypeEnum.SERVICE_PROJECT.getAlias(),
            XbbRefTypeEnum.SERVICE_PROJECT.getCode(), AccessLinkEnum.SERVICE_PROJECT, XbbRefTypeEnum.WORK_ORDER_V2_CENTER.getAlias(), MenuTypeEnum.MENU.getType()),

    // SLA日志
    SLA_LOG(XbbRefTypeEnum.SLA_LOG.getName(), XbbRefTypeEnum.SLA_LOG.getAlias(),
            XbbRefTypeEnum.SLA_LOG.getCode(), AccessLinkEnum.SLA_LOG, "", MenuTypeEnum.MENU.getType()),

    ;

    /**
     * saas应用标示解释
     */
    private final String name;
    /**
     * saas应用标示
     *
     * @see XbbRefTypeEnum
     */
    private final String alias;
    /**
     * @see XbbRefTypeEnum
     */
    private final Integer code;
    /**
     * 对应的链接
     */
    private final AccessLinkEnum accessLinkEnum;

    /**
     * 父节点，如果没有父节点，则此值为空字符串
     */
    private final String parent;

    /**
     * 类型
     *
     * @see MenuTypeEnum
     */
    private final Integer type;

    WorkOrderV2CenterMenuEnum(String name, String alias, Integer code, AccessLinkEnum accessLinkEnum, String parent, Integer type) {
        this.name = name;
        this.alias = alias;
        this.code = code;
        this.accessLinkEnum = accessLinkEnum;
        this.parent = parent;
        this.type = type;
    }

    public static WorkOrderV2CenterMenuEnum getByAlias(String alias) {
        for (WorkOrderV2CenterMenuEnum centerMenuEnum : values()) {
            if (centerMenuEnum.getAlias().equals(alias)) {
                return centerMenuEnum;
            }
        }
        return null;
    }

    public static WorkOrderV2CenterMenuEnum getByCode(Integer code) {
        for (WorkOrderV2CenterMenuEnum centerMenuEnum : values()) {
            if (centerMenuEnum.getCode().equals(code)) {
                return centerMenuEnum;
            }
        }
        return null;
    }

    public String getName() {
        return I18nMessageUtil.getMessage(name);
    }
}
